﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using SystemDirectory.DAO;
using SystemDirectory.Entity;

namespace SystemDirectory.Biz
{
    public class BOContact
    {
        public DataTable Get(string FirstName, string SurName, bool ShowInactive)
        {
            DAOContact daoContact = new DAOContact();
            DataTable dtResult = daoContact.Get(FirstName, SurName, ShowInactive);
            DataTable dtReturn = dtResult.Clone();
            dtReturn.Columns["ContactTypeId"].DataType = typeof(String);
            int i = 0;
            foreach (DataRow item in dtResult.Rows)
            {
                dtReturn.ImportRow(item);

            }
            foreach (DataRow item in dtReturn.Rows)
            {
                if (item["ContactTypeId"].ToString() == "1")
                {
                    item["ContactTypeId"] = "Test01";
                }
            }
            return dtReturn;

        }

        public bool Add(Contact ContactIn)
        {
            DAOContact daoContact = new DAOContact();
            return daoContact.Add(ContactIn);
        }

        public Contact GetById(int id) {
            DAOContact daoContact = new DAOContact();
            return daoContact.GetById(id);
        }

        public bool Update(Contact ContactIn)
        {
            DAOContact daoContact = new DAOContact();
            return daoContact.Update(ContactIn);
        }
    }
}